﻿using Furion.DatabaseAccessor;
using Furion.DependencyInjection;
using System;

namespace Jiffy.Core.Sys.Dto
{
    /// <summary>
    /// <c>【系统领域】</c>
    /// 仓储接口
    /// </summary>
    /// <typeparam name="TEntity"></typeparam>
    /// <typeparam name="TDbContextLocator"></typeparam>
    public interface ISysRepository<TEntity, TDbContextLocator> : IPrivateRepository<TEntity>
        where TEntity : class, IPrivateEntity, new()
        where TDbContextLocator : class, IDbContextLocator
    {
    }

    /// <summary>
    /// <c>【系统领域】</c>
    /// 自定义仓储实现类
    /// </summary>
    /// <typeparam name="TEntity"></typeparam>
    /// <typeparam name="TDbContextLocator"></typeparam>
    public class SysRepository<TEntity, TDbContextLocator> : PrivateRepository<TEntity>, ISysRepository<TEntity, TDbContextLocator>, IScoped
        where TEntity : class, IPrivateEntity, new()
        where TDbContextLocator : class, IDbContextLocator
    {
        /// <summary>
        /// 实现基类构造函数
        /// </summary>
        /// <param name="serviceProvider"></param>
        public SysRepository(IServiceProvider serviceProvider)
            : base(typeof(TDbContextLocator), serviceProvider)
        {
        }
    }

    /// <summary>
    /// <c>【系统领域】</c>
    /// 仓储接口
    /// </summary>
    /// <typeparam name="TEntity"></typeparam>
    public interface ISysRepository<TEntity> : ISysRepository<TEntity, SysDbContextLocator>
    where TEntity : class, IPrivateEntity, new()
    {
    }

    /// <summary>
    /// <c>【系统领域】</c>
    /// 仓储实现
    /// </summary>
    /// <typeparam name="TEntity"></typeparam>
    public class SysRepository<TEntity> : SysRepository<TEntity, SysDbContextLocator>, ISysRepository<TEntity>, IScoped
        where TEntity : class, IPrivateEntity, new()
    {
        public SysRepository(IServiceProvider serviceProvider) : base(serviceProvider)
        {
        }
    }
}
